package com.seednia.foundation.framework.dto;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;

import com.seednia.foundation.framework.dto.AbstractRecord;
import com.seednia.module.core.category.dto.CategoryDto;

/**
 * Entity Class com.seednia.module.core.profile.dto.ProfileAttributeDto
 * Generated by hbm2java_entity_class.ftl (v20110614)
 *
 * @author Young Suk Ahn
 */
@XmlRootElement(name = "AttributeDto", 
		namespace = "http://seednia.com/foundation/1.0")
@XmlType(name = "AttributeDto")
@XmlAccessorType(XmlAccessType.FIELD)
@JsonIgnoreProperties({ "creatorDto", "categoryDto" }) // For jackson
public class AttributeDto extends AbstractRecord implements ICategorizable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -8230496107538204298L;
	
	private long targetSid = 0; /* The record Sid that this attribute belongs to  */ 
	private int position = 0; /* The display ordering (within category-profile)  */ 
	private String kind = null; /* Kind of attribute (contact, website).  */ 
	private String name = null; /* Name of the attribute: home email, work email, etc.  */ 
	private String value = null; /* The value of this attribute  */ 
	private java.util.Date eventDate = null; /* The date of this event (honor, award, etc.)   */

	// Many to one mappings:
	private com.seednia.module.core.user.dto.UserDto creatorDto = null; /* The author of the post  */ 
	private com.seednia.module.core.category.dto.CategoryDto categoryDto = null; /* The category of this object  */ 

	public long getTargetSid() {
		return targetSid;
	}
	public void setTargetSid(long targetSid) {
		//long old = this.profileSid;
        //this.vcs.fireVetoableChange( "profileSid", old, profileSid );
		this.targetSid = targetSid;
        //this.pcs.firePropertyChange( "profileSid", old, profileSid );
	}
	public String getKind() {
		return kind;
	}
	public void setKind(String kind) {
		this.kind = kind;
	}
	public int getPosition() {
		return position;
	}
	public void setPosition(int position) {
		//int old = this.position;
        //this.vcs.fireVetoableChange( "position", old, position );
		this.position = position;
        //this.pcs.firePropertyChange( "position", old, position );
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		//String old = this.name;
        //this.vcs.fireVetoableChange( "name", old, name );
		this.name = name;
        //this.pcs.firePropertyChange( "name", old, name );
	}
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		//String old = this.value;
        //this.vcs.fireVetoableChange( "value", old, value );
		this.value = value;
        //this.pcs.firePropertyChange( "value", old, value );
	}
	public java.util.Date getEventDate() {
		return eventDate;
	}
	public void setEventDate(java.util.Date eventDate) {
		//java.util.Date old = this.eventDate;
        //this.vcs.fireVetoableChange( "eventDate", old, eventDate );
		this.eventDate = eventDate;
        //this.pcs.firePropertyChange( "eventDate", old, eventDate );
	}


	// Many-to-one mappings:
	public com.seednia.module.core.user.dto.UserDto getCreatorDto() {
		return creatorDto;
	}
	public void setCreatorDto(com.seednia.module.core.user.dto.UserDto creatorDto) {
		//com.seednia.module.core.user.dto.UserDto old = this.creatorDto;
        //super.vcs.fireVetoableChange( "creatorDto", old, creatorDto );
		this.creatorDto = creatorDto;
        //super.pcs.firePropertyChange( "creatorDto", old, creatorDto );
	}
	public com.seednia.module.core.category.dto.CategoryDto getCategoryDto() {
		return categoryDto;
	}
	public void setCategoryDto(com.seednia.module.core.category.dto.CategoryDto categoryDto) {
		//com.seednia.module.core.category.dto.CategoryDto old = this.categoryDto;
        //super.vcs.fireVetoableChange( "categoryDto", old, categoryDto );
		this.categoryDto = categoryDto;
        //super.pcs.firePropertyChange( "categoryDto", old, categoryDto );
	}
	
	@Override
	public Long getCreatorSid() {
		return creatorDto != null ? creatorDto.getSid() : null;
	}
	@Override
	public String getCreatorId() {
		return creatorDto != null ? creatorDto.getId() : null;
	}
	
	// From ICategorizable
	
	@Override
	public Long getCategorySid() {
		return (this.getCategoryDto() != null) ? getCategoryDto().getSid() :  null;
	}
	@Override
	public void setCategorySid(Long categorySid) {
		// This shall only be used by the automatic property loader
		if (this.getCategoryDto() == null){
			categoryDto = new CategoryDto();
		}
		categoryDto.setSid(categorySid);
	}
	@Override
	public String getCategoryName() {
		return (this.getCategoryDto() != null) ? getCategoryDto().getName() :  null;
	}
	@Override
	public void setCategoryName(String categoryName) {
		if (this.getCategoryDto() != null) 
		{
			this.getCategoryDto().setName(categoryName);
		}else {
			throw new IllegalStateException("You cannot set category name directly.");
		}
	}
}